#!/bin/sh

## REMINDER: YOU NEED TO RUN THIS SCRIPT VIA SUDO

#################################################
##    KILL THE EXECUTION OF THE EXECUTABLES    ##
#################################################

ps -axcopid,command | grep "Iceberg*" | awk '{ system("kill -9 "$1) }'

ps -axcopid,command | grep "IcebergControlTowerTool*" | awk '{ system("kill -9 "$1) }'

ps -axcopid,command | grep "IcebergBuilder*" | awk '{ system("kill -9 "$1) }'

#################################################
##         REMOVE THE FILES FROM DISK          ##
#################################################

## APPLICATION

if [ -d /Applications/Iceberg.app ]; then
   rm -r /Applications/Iceberg.app
fi

## APPLICATION SUPPORT

if [ -d /Library/Application\ Support/Iceberg ]; then
   rm -r /Library/Application\ Support/Iceberg
fi

## FRAMEWORKS

## We don't remove the MOKit Framework because it can be used by other applications.

## STARTUPITEM

if [ -d /Library/StartupItems/IcebergControlTower ]; then
   rm -r /Library/StartupItems/IcebergControlTower
fi

## BINARY TOOL

if [ -f /usr/bin/freeze ]; then
   rm /usr/bin/freeze
fi

## RECEIPTS

if [ -d /Library/Receipts/Iceberg.pkg ]; then
	rm -r /Library/Receipts/Iceberg.pkg
fi